<template>
  <div class="helpText">
    <div v-for="(val, index) in content" :key="index">
      <div v-for="(item, index1) in val.childs" :key="index1">
        <div v-if="title == item.title">
          <!-- 头部标题  -->
          <div class="title" v-html="item.title"></div>
          <!-- 日期  -->
          <p class="date" v-html="item.date"></p>
          <!-- 正文  -->
          <div v-html="item.content"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    content: { // 帮助中心全部信息
      type: Array,
      default: () => { return {} }
    }
  },
  data() {
    return {
      title: ''
    }
  },
  // 监听$router
  watch: {
    '$route' (to, from) {
      this.fetchTitle()
    }
  },
  created() {
    this.fetchTitle()
  },
  methods: {
    fetchTitle() {
      // 让页面跳转到顶部
      window.scroll(0, 0)
      this.title = this.$route.params.title
    }
  }
}
</script>

<style lang="scss">
  @import '../../scss/_var.scss';
  .helpText {
    background-color: $color-white;
    padding: 0 55px 40px;
    .title {
      text-align: center;
      font-size: 16px;
      padding: 12px 0;
      border-bottom: 1px solid #dddddd;
      font-weight: 600;
    }
    .date {
      color: $color-disabled;
      text-align: center;
      margin: 10px auto 18px;
      font-size: 12px;
    }
    img {
      width: auto;
      height: auto;
      max-width: 100%;
    }
  }
</style>
